package com.lehecai.core.api.message;

import com.lehecai.core.IntegerBeanLabelItem;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * Created by zhangzq on 14-4-11.
 */
public class MessageType extends IntegerBeanLabelItem {

    private static final Logger logger = LoggerFactory.getLogger(MessageType.class.getName());
    private static final long serialVersionUID = -1;

    private static List<MessageType> _items = new ArrayList<MessageType>();
    private static List<MessageType> items;

    protected MessageType(String name, int value) {
        super(MessageType.class.getName(), name, value);
        _items.add(this);
    }

    public static MessageType getItem(int value){
        try {
            return (MessageType) MessageType.getResult(MessageType.class.getName(), value);
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            return null;
        }
    }

    /**
     * @return
     */
    public static List<MessageType> getItems() {
        return items;
    }
    public static final MessageType ALL = new MessageType("全部", -1);
    public static final MessageType MESSAGE_NOTICE = new MessageType("公告类", 1);
    public static final MessageType MESSAGE_REMIND = new MessageType("提醒类", 2);
    public static final MessageType MESSAGE_SUBSCRIBE = new MessageType("订阅类", 3);

    static {
        synchronized (_items) {
            items = Collections.unmodifiableList(_items);
        }
    }
}
